﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace MainProject
{
    public partial class MainForm : Form
    {
        private int childFormNumber = 0;

        public MainForm()
        {
            InitializeComponent();
        }

        private void ShowNewForm(object sender, EventArgs e)
        {
            Form childForm = new Form();
            childForm.MdiParent = this;
            childForm.Text = "Window " + childFormNumber++;
            childForm.Show();
        }

        private void ExitToolsStripMenuItem_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void CascadeToolStripMenuItem_Click(object sender, EventArgs e)
        {
            LayoutMdi(MdiLayout.Cascade);
        }

        private void TileVerticalToolStripMenuItem_Click(object sender, EventArgs e)
        {
            LayoutMdi(MdiLayout.TileVertical);
        }

        private void TileHorizontalToolStripMenuItem_Click(object sender, EventArgs e)
        {
            LayoutMdi(MdiLayout.TileHorizontal);
        }

        private void ArrangeIconsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            LayoutMdi(MdiLayout.ArrangeIcons);
        }

        private void CloseAllToolStripMenuItem_Click(object sender, EventArgs e)
        {
            foreach (Form childForm in MdiChildren)
            {
                childForm.Close();
            }
        }

        private void MainForm_Load(object sender, EventArgs e)
        {
        }

        private void ShowChild(Type _typeF)
        {
            bool flag = false;
            foreach (Form _form in this.MdiChildren)
            {
                if (_form.GetType() == _typeF)
                {
                    flag = true;
                    _form.Activate();
                }
            }
            if (!flag)
            {
                Form _form = (Form)Activator.CreateInstance(_typeF);
                _form.MdiParent = this;
                _form.WindowState = FormWindowState.Maximized;
                _form.Show();
            }
        }

        private void kháchHàngToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ShowChild(typeof(Quanlykhachhang.Quanlykhachhang));   
        }       

        private void tàiXếToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ShowChild(typeof(Quanlytaixe.Quanlytaxe));
        }

        private void danhSáchHàngHóaToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ShowChild(typeof(Quanlyhanghoa.Quanlyhanghoa));            
        }

        private void loạiHàngHóaToolStripMenuItem_Click(object sender, EventArgs e)
        {
           ShowChild(typeof(Quanlyloaihanghoa.Quanlyloaihanghoa));
        }

        private void qToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ShowChild(typeof(Quanlyxe.Quanlyxe));
        }

        private void loạiXeToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ShowChild(typeof(Quanlyhangxe.Quanlyhangxe));
        }

        private void hiệuXeToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ShowChild(typeof(Quanlyhieuxe.Quanlyhieuxe));
        }

        private void vậnChuyểnHàngHóaToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Vanchuyen.Vanchuyenwizard vc = new Vanchuyen.Vanchuyenwizard();
            vc.ShowDialog();
        }
    }
}
